#include <stdio.h>
#include <stdlib.h>

#include "stack_int.h"
#include "list_int.h"
#include "queue_int.h"
#include "BinTree_int.h"

void stack_test() {
	Stack s = stack_create(10);
	for (int i = 0; i < 5; i++)
		stack_push(s, i);
	while (!stack_is_empty(s))
		printf("%d ", stack_pop(s));
	printf("\n");
	stack_free(s);
}

void linkedlist_test() {
	LinkedList list = linked_list_create(0, NULL);
	for (int i = 0; i < 5; i++)
		linked_list_push(list, i);
	LinkedList head = list->next;
	while (head)
	{
		printf("%d ", head->data);
		head = head->next;
	}
	printf("\n");
	linked_list_free(list);
}

void queue_test() {
	Queue queue = queue_create();
	for (int i = 0; i < 10; i++)
		queue_push(queue, i);
	while (!queue_is_empty(queue))
	{
		printf("%d ", queue_pop(queue));
	}
	printf("%d", queue_is_empty(queue));
	printf("\n");
	queue_free(queue);
}

void test_bin_tree() {
	BinTree bt = bintree_create(10);

	bintree_insert(bt, 5);
	bintree_insert(bt, 3);
	bintree_insert(bt, 8);
	bintree_insert(bt, 15);
	bintree_insert(bt, 12);
	bintree_insert(bt, 18);

	bintree_preorder_traversal(bt);
	bintree_inorder_traversal(bt);
	bintree_postorder_traversal(bt);
	bintree_postorder_traversal0(bt);
	printf("\n");

	bintree_free(bt);
}


int main() {
	stack_test();
	linkedlist_test();
	queue_test();
	test_bin_tree();
	return 0;
}